{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np #导入numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index(['a', 'b', 'c', 'd', 'e'], dtype='object')\n",
      "a\n",
      "b\n",
      "c\n",
      "d\n",
      "e\n",
      "[11 22 33 44 55]\n",
      "1\n",
      "(5,)\n",
      "5\n",
      "int64\n",
      "int64\n",
      "atguigu\n",
      "33\n",
      "c    33\n",
      "d    44\n",
      "Name: atguigu, dtype: int64\n",
      "11\n",
      "a    11\n",
      "b    22\n",
      "c    33\n",
      "Name: atguigu, dtype: int64\n",
      "11\n",
      "44\n"
     ]
    }
   ],
   "source": [
    "arrs = pd.Series([11,22,33,44,55],name=\"atguigu\",index=[\"a\",\"b\",\"c\",\"d\",\"e\"])\n",
    "# print(arrs)\n",
    "# index Series的索引对象\n",
    "print(arrs.index)\n",
    "for i in arrs.index:\n",
    "    print(i)\n",
    "# values    Series的值\n",
    "print(arrs.values)\n",
    "# ndim  Series的维度\n",
    "print(arrs.ndim)\n",
    "# shape Series的形状\n",
    "print(arrs.shape)\n",
    "# size  Series的元素个数\n",
    "print(arrs.size)\n",
    "# dtype或dtypes  Series的元素类型\n",
    "print(arrs.dtype)\n",
    "print(arrs.dtypes)\n",
    "\n",
    "# name  Series的名称\n",
    "print(arrs.name)\n",
    "# loc[] 显式索引，按标签索引或切片\n",
    "print(arrs.loc[\"c\"])\n",
    "print(arrs.loc[\"c\":\"d\"])\n",
    "# iloc[]    隐式索引，按位置索引或切片\n",
    "print(arrs.iloc[0])\n",
    "print(arrs.iloc[0:3])\n",
    "# at[]  使用标签访问单个元素\n",
    "print(arrs.at[\"a\"])\n",
    "# iat[] 使用位置访问单个元素\n",
    "print(arrs.iat[3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    11.0\n",
      "b    22.0\n",
      "c     NaN\n",
      "d     NaN\n",
      "e    44.0\n",
      "dtype: float64\n",
      "d     NaN\n",
      "e    44.0\n",
      "f    22.0\n",
      "dtype: float64\n",
      "--------------------\n",
      "a     True\n",
      "b    False\n",
      "c    False\n",
      "d    False\n",
      "e    False\n",
      "f    False\n",
      "dtype: bool\n",
      "a    False\n",
      "b    False\n",
      "c     True\n",
      "d     True\n",
      "e    False\n",
      "f    False\n",
      "dtype: bool\n",
      "99.0\n",
      "--------------------\n",
      "24.75\n",
      "11.0\n",
      "44.0\n",
      "191.58333333333334\n",
      "13.841363131329707\n",
      "-------------------- wwww --------------------\n",
      "22.0\n",
      "0    22.0\n",
      "dtype: float64\n"
     ]
    }
   ],
   "source": [
    "arrs = pd.Series([11,22,np.nan,None,44,22],index=['a','b','c','d','e','f'])\n",
    "# head()    查看前n行数据，默认5行\n",
    "print(arrs.head())\n",
    "# tail()    查看后n行数据，默认5行\n",
    "print(arrs.tail(3))\n",
    "print(\"-\" * 20)\n",
    "# isin()    判断数组中的每一个元素是否包含在参数集合中\n",
    "print(arrs.isin([11]))\n",
    "# isna()    元素是否为缺失值\n",
    "print(arrs.isna())\n",
    "# sum() 求和，会忽略 Series 中的缺失值\n",
    "print(arrs.sum())\n",
    "print(\"-\" * 20)\n",
    "# mean()    平均值\n",
    "print(arrs.mean())\n",
    "# min() 最小值\n",
    "print(arrs.min())\n",
    "# max() 最大值\n",
    "print(arrs.max())\n",
    "# var() 方差\n",
    "print(arrs.var())\n",
    "# std() 标准差\n",
    "print(arrs.std())\n",
    "print(\"-\" * 20,'wwww',\"-\" * 20)\n",
    "# median()  中位数\n",
    "# 若数据集的元素个数为奇数，中位数就是排序后位于中间位置的数值。\n",
    "# 若数据集的元素个数为偶数，中位数则是排序后中间两个数的平均值。\n",
    "# 去除缺失值之后，arrs 就变成了 [11, 22, 44, 22]。\n",
    "# 对 [11, 22, 44, 22] 进行排序，得到 [11, 22, 22, 44]\n",
    "print(arrs.median())\n",
    "# mode()    众数\n",
    "print(arrs.mode())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "16.5\n",
      "count     4.000000\n",
      "mean     24.750000\n",
      "std      13.841363\n",
      "min      11.000000\n",
      "25%      19.250000\n",
      "50%      22.000000\n",
      "75%      27.500000\n",
      "max      44.000000\n",
      "dtype: float64\n",
      "22.0    2\n",
      "11.0    1\n",
      "44.0    1\n",
      "dtype: int64\n",
      "4\n",
      "6\n",
      "a    11.0\n",
      "b    22.0\n",
      "c     NaN\n",
      "e    44.0\n",
      "dtype: float64\n",
      "[11. 22. nan 44.]\n",
      "3\n",
      "e    44.0\n",
      "dtype: float64\n",
      "a    11.0\n",
      "b    22.0\n",
      "c     NaN\n",
      "d     NaN\n",
      "e    44.0\n",
      "f    22.0\n",
      "dtype: float64\n",
      "a    11.0\n",
      "b    22.0\n",
      "f    22.0\n",
      "e    44.0\n",
      "c     NaN\n",
      "d     NaN\n",
      "dtype: float64\n",
      "a    11.0\n",
      "b    haha\n",
      "c     NaN\n",
      "d     NaN\n",
      "e    44.0\n",
      "f    haha\n",
      "dtype: object\n",
      "      0\n",
      "a  11.0\n",
      "b  22.0\n",
      "c   NaN\n",
      "d   NaN\n",
      "e  44.0\n",
      "f  22.0\n",
      "True\n",
      "Index(['a', 'b', 'c', 'd', 'e', 'f'], dtype='object')\n",
      "Index(['a', 'b', 'c', 'd', 'e', 'f'], dtype='object')\n",
      "1.0\n",
      "-1.0\n",
      "1.0\n",
      "0.0\n",
      "-1.0\n",
      "0 3\n",
      "1 2\n",
      "2 1\n",
      "3 1\n",
      "4 1\n",
      "5 2\n",
      "6 2\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGdCAYAAAD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hjq1Kn67ne/q9/+9rfavHmzjaX22tixYzV27NjgcWZmpk6fPq1NmzZpxowZwXG33IclJSUaNGiQFixYEDIejffhE088oQ8++EDvvPNOj3NjdR86ydgulvZhb/PF6j4M5/6LlT04duxYHTt2TBcuXFBZWZmWLl2qqqqqLgtJNOzBm/aZkeHDh3dodefOnVN8fLyGDBnS7ZyvN8Rot2vXLj322GP6wx/+oAcffLDbuXFxcZo8eXJMPDPSmSlTpoSs3S33oTFG27Zt0+LFi9W3b99u59q+D1etWqXdu3frwIEDGjlyZLdzY3UfOsnYLpb2YTj5rhXt+zCcfLG0B/v27as77rhDGRkZ2rBhg+699169+OKLnc6Nlj1405aRzMxMVVRUhIzt379fGRkZSkhI6HbOfffd942t83q99tprWrZsmUpLS/WDH/ygx/nGGB07dkwpKSnfwOoir7a2NmTtbrgPpa9+CuCTTz7RY4891uNcW/ehMUZPPPGE3njjDf3lL39RWlpaj+fE2j4MJ6MUO/sw3HxfF6378HryxcIe7IoxRn6/v9PbomYPRuytsJZdvHjR1NbWmtraWiPJvPDCC6a2ttacOnXKGGPMU089ZRYvXhyc/+9//9v079/frFmzxvz97383xcXFJiEhwfzxj38Mznn33XdNnz59zMaNG83x48fNxo0bTXx8vDly5Mg3ns8Y5xlLS0tNfHy82bJli2loaAh+XLhwITgnPz/f7Nu3z/zrX/8ytbW15pFHHjHx8fHmvffei/p8//d//2fKy8vNP/7xD/PRRx+Zp556ykgyZWVlwTmxfh+2+9nPfma+973vdXrNaLkPf/GLX5iBAweaysrKkK+31tbW4JxY34fhZIylfRhOvljah+HkaxcLe9AYY3Jzc011dbU5efKk+eCDD0xeXp6Ji4sz+/fvN8ZE7x50TRlp//Gyr38sXbrUGGPM0qVLzcyZM0POqaysNJMmTTJ9+/Y1o0ePNoWFhR2u+/rrr5uxY8eahIQEc/fdd4dssG+a04wzZ87sdr4xxjz55JNm1KhRpm/fvua2224zPp/PHDp06JsN9j9O8/3617823/72t01iYqK59dZbzbRp08yePXs6XDeW70NjjLlw4YLp16+f2bp1a6fXjJb7sLNcksz27duDc2J9H4aTMZb2YTj5Ymkfhvs1Git70BhjHn30UXP77bcH1zJ79uxgETEmevegx5j/vVMFAADAgpv2PSMAACA6UEYAAIBVlBEAAGAVZQQAAFhFGQEAAFZRRgAAgFWUEQAAYBVlBAAAWEUZAQAAVlFGAACAVZQRAABgFWUEAABY9f9Tm0yXYqU1zQAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "print(arrs.quantile(0.25, interpolation=\"midpoint\"))\n",
    "\n",
    "# describe()    常见统计信息\n",
    "print(arrs.describe())\n",
    "# value_counts()    每个元素的个数\n",
    "print(arrs.value_counts())\n",
    "# count()   非缺失值元素的个数\n",
    "print(arrs.count())\n",
    "print(len(arrs))\n",
    "# drop_duplicates() 去重  这里可以看出，底层None也作为NaN处理\n",
    "print(arrs.drop_duplicates())\n",
    "# unique()  去重后的数组\n",
    "print(arrs.unique())\n",
    "\n",
    "# nunique() 去重后非缺失值元素元素个数\n",
    "print(arrs.nunique())\n",
    "# sample()  随机采样\n",
    "print(arrs.sample())\n",
    "\n",
    "# sort_index()  按索引排序\n",
    "print(arrs.sort_index())\n",
    "\n",
    "# sort_values() 按值排序\n",
    "print(arrs.sort_values())\n",
    "# replace() 用指定值代替原有值\n",
    "print(arrs.replace(22,\"haha\"))\n",
    "\n",
    "# to_frame()    将Series转换为DataFrame\n",
    "print(arrs.to_frame())\n",
    "\n",
    "# equals()  判断两个Series是否相同\n",
    "arr1 = pd.Series([1,2,3])\n",
    "arr2 = pd.Series([1,2,3])\n",
    "print(arr1.equals(arr2))\n",
    "# keys()    返回Series的索引对象\n",
    "print(arrs.index)\n",
    "print(arrs.keys())\n",
    "# corr()    计算与另一个Series的相关系数\n",
    "# arr1.corr(arr2)：由于 arr1 和 arr2 的值完全相同，它们之间是完全正相关的，\n",
    "#因此相关系数为 1。\n",
    "# arr1.corr(arr3)：arr1 的值是递增的，而 arr3 的值是递减的，它们之间是完全\n",
    "# 负相关的，所以相关系数为 -1。\n",
    "# arr1.corr(arr4)：arr1 和 arr4 的值都是递增的，且变化趋势一致，它们之间是\n",
    "# 完全正相关的，相关系数为 1。\n",
    "# arr5.corr(arr6)：arr5 和 arr6 的值之间没有明显的线性关系，它们的相关系数\n",
    "# 为 0。\n",
    "arr3 = pd.Series([3,2,1])\n",
    "arr4 = pd.Series([6,7,8])\n",
    "arr5 = pd.Series([1, -1, 1, -1])\n",
    "arr6 = pd.Series([1, 1, -1, -1])\n",
    "print(arr1.corr(arr2))\n",
    "print(arr1.corr(arr3))\n",
    "print(arr1.corr(arr4))\n",
    "print(arr5.corr(arr6))\n",
    "\n",
    "# cov() 计算与另一个Series的协方差\n",
    "# 协方差用于衡量两个变量的总体误差，其值的正负表示两个变量的变化方向关系：\n",
    "# 正值表示同向变化，负值表示反向变化。\n",
    "print(arr1.cov(arr3))\n",
    "\n",
    "# hist()    绘制直方图\n",
    "arr7 = pd.Series([3,2,1,1,1,2,2])\n",
    "# 绘制直方图\n",
    "# 直方图（Histogram）是一种用于展示数据分布的统计图表，它通过将数据划分为\n",
    "# 若干个连续的区间（ bins ），统计每个区间内数据的频数或频率，并用矩形条的\n",
    "# 高度表示该区间的数值分布情况\n",
    "arr7.hist(bins=3)\n",
    "# items()   获取索引名以及值\n",
    "for i,v in arr7.items():\n",
    "    print(i,v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    False\n",
      "b     True\n",
      "c     True\n",
      "d    False\n",
      "dtype: bool\n"
     ]
    }
   ],
   "source": [
    "s = pd.Series({\"a\": -1.2, \"b\": 3.5, \"c\": 6.8, \"d\": 2.9})\n",
    "bools = s > s.mean()# 将大于平均值的元素标记为 True\n",
    "print(bools)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a   -12.0\n",
      "b    35.0\n",
      "c    68.0\n",
      "d    29.0\n",
      "dtype: float64\n",
      "0    NaN\n",
      "1    3.0\n",
      "2    3.0\n",
      "3    3.0\n",
      "4    NaN\n",
      "dtype: float64\n"
     ]
    }
   ],
   "source": [
    "s = pd.Series({\"a\": -1.2, \"b\": 3.5, \"c\": 6.8, \"d\": 2.9})\n",
    "print(s * 10)\n",
    "\n",
    "s1 = pd.Series([1, 1, 1, 1])\n",
    "s2 = pd.Series([2, 2, 2, 2], index=[1, 2, 3, 4])\n",
    "print(s1 + s2)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
